/* 商品列表
 */

import { postRequest, getRequest, getDownload, uploadRequest } from '@/lib/axios'
interface GoodsApi {
  queryList(param: PageParamModel): Promise<any>
  create(data: any): Promise<any>
  update(data: any): Promise<any>
  modify(data: any): Promise<any>
  batchShelveOff(data: any): Promise<any>
  delete(data: { id: string }): Promise<any>
  deleteSpec(data: { id: number }): Promise<any>
  downloadExcel(data: { id: string }): void
  importGoods(data: any): Promise<any>
  exportGoods(params?: any): void
  queryCategoryList(): Promise<any>
  createCategory(data: any): Promise<any>
  updateCategory(data: any): Promise<any>
  deleteCategory(data: any): Promise<any>
  queryBrandList(param: any): Promise<any>
  createBrand(data: any): Promise<any>
  updateBrand(data: any): Promise<any>
  deleteBrand(data: any): Promise<any>
}
export const goodsApi: GoodsApi = {
  // 商品分页查询 @author zhuoda
  queryList: (param) => {
    return getRequest('/goods/list', param)
  },
  // 新增
  create: (data) => {
    return postRequest('/goods/add', data)
  },
  // 编辑
  update: (data) => {
    return postRequest('/goods/edit', data)
  },
  // 修改
  modify: (data) => {
    return postRequest('/goods/modify', data)
  },
  // 批量上下架
  batchShelveOff: (data) => {
    return postRequest('/goods/batch-shelve-off', data)
  },
  // 删除
  delete: (data) => {
    return postRequest('/goods/del', data)
  },
  deleteSpec: (data) => {
    return postRequest('/goods/del_spec', data)
  },
  // 下载模版
  downloadExcel: () => {
    return getDownload('/goods/export_template')
  },
  // 导入商品
  importGoods: (data) => {
    return uploadRequest('/goods/import', data)
  },
  // 导出商品
  exportGoods: (params) => {
    return getDownload('/goods/export', params)
  },
  // 商品分类
  queryCategoryList: () => {
    return getRequest('/goods_category/list')
  },
  // 商品分类新增
  createCategory: (data) => {
    return postRequest('/goods_category/add', data)
  },
  // 商品分类编辑
  updateCategory: (data) => {
    return postRequest('/goods_category/edit', data)
  },
  // 商品分类删除
  deleteCategory: (data) => {
    return postRequest('/goods_category/del', data)
  },
  // 商品品牌
  queryBrandList: (param) => {
    return getRequest('/goods_brand/list', param)
  },
  // 商品品牌新增
  createBrand: (data) => {
    return postRequest('/goods_brand/add', data)
  },
  // 商品品牌编辑
  updateBrand: (data) => {
    return postRequest('/goods_brand/edit', data)
  },
  // 商品品牌删除
  deleteBrand: (data) => {
    return postRequest('/goods_brand/del', data)
  }
}
